 <template>
	<div class="wrapper" ref="wrapper">
		<slot></slot>
	</div>
</template>
<script>
	import BScroll from 'better-scroll'
	export default {
		name:'Btscroll',
		data(){
			return {
				bscroll:null 

			}
		},
		mounted(){
			//this.$nextTick(() => {
				//BScroll中probeType是否时时侦测位置；1 不侦测，2 在手指滚动的过程中侦测，3 手指离开屏幕后惯性滚动的位置也侦测
				this.bscroll = new BScroll(this.$refs.wrapper,{
					probeType:3
				})
			//}),
			this.bscroll.on('scroll',(position) =>{
				//发送scrool事件，并传递参数position
				this.$emit('scroll',position)
				//console.log(position)
			})		
		},
		methods:{
			bscrollTo (x,y,time=500) {
				this.bscroll.scrollTo(x,y,time)
			}
		}
	}
</script>
<style>
	.wrapper{
		height: 250px;
		overflow: hidden
	}
</style>